{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2012-03-09 09:30:00+08:00', '2012-03-10 09:30:00+08:00',\n",
       "               '2012-03-11 09:30:00+08:00', '2012-03-12 09:30:00+08:00',\n",
       "               '2012-03-13 09:30:00+08:00'],\n",
       "              dtype='datetime64[ns, Asia/Shanghai]', freq='D')"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.date_range('3/9/2012 9:30', periods=5, freq='D', tz='Asia/Shanghai')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2012-03-09 09:30:00+08:00', '2012-03-10 09:30:00+08:00',\n",
       "               '2012-03-11 09:30:00+08:00', '2012-03-12 09:30:00+08:00',\n",
       "               '2012-03-13 09:30:00+08:00'],\n",
       "              dtype='datetime64[ns, Asia/Shanghai]', freq='D')"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.date_range('3/9/2012 9:30', periods=5, freq='D').tz_localize('Asia/Shanghai')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2012-03-09 09:30:00+08:00', '2012-03-10 09:30:00+08:00',\n",
       "               '2012-03-11 09:30:00+08:00', '2012-03-12 09:30:00+08:00',\n",
       "               '2012-03-13 09:30:00+08:00'],\n",
       "              dtype='datetime64[ns, Asia/Shanghai]', freq='D')"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts_shanghai = pd.date_range('3/9/2012 9:30', periods=5, freq='D', tz='Asia/Shanghai')\n",
    "ts_shanghai"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2012-03-09 01:30:00+00:00', '2012-03-10 01:30:00+00:00',\n",
       "               '2012-03-11 01:30:00+00:00', '2012-03-12 01:30:00+00:00',\n",
       "               '2012-03-13 01:30:00+00:00'],\n",
       "              dtype='datetime64[ns, UTC]', freq='D')"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts_shanghai.tz_convert('UTC')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2012-03-08 20:30:00-05:00', '2012-03-09 20:30:00-05:00',\n",
       "               '2012-03-10 20:30:00-05:00', '2012-03-11 21:30:00-04:00',\n",
       "               '2012-03-12 21:30:00-04:00'],\n",
       "              dtype='datetime64[ns, America/New_York]', freq='D')"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts_shanghai.tz_convert('America/New_York')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2012-03-09 09:30:00-05:00', '2012-03-10 09:30:00-05:00',\n",
       "               '2012-03-11 09:30:00-04:00', '2012-03-12 09:30:00-04:00',\n",
       "               '2012-03-13 09:30:00-04:00'],\n",
       "              dtype='datetime64[ns, US/Eastern]', freq='D')"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts_shanghai.tz_localize(None).tz_localize('US/Eastern')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
